class_name HealthBar
extends Control

@export var back_color:Color
@export var fill_color: Color

@onready var progress_bar: ProgressBar = $ProgressBar
@onready var health_amount: Label = $HealthAmount

func _ready() -> void:
	var back_style := progress_bar.get_theme_stylebox("background").duplicate() as StyleBoxFlat
	var fill_style := progress_bar.get_theme_stylebox("fill").duplicate() as StyleBoxFlat
	back_style.bg_color = back_color
	fill_style.bg_color = fill_color
	progress_bar.add_theme_stylebox_override("background", back_style)
	progress_bar.add_theme_stylebox_override("fill", fill_style)
	
func update_bar(value: float, current_health: float) -> void:
	progress_bar.value = value
	health_amount.text = str(current_health)
